cd $(dirname $0)

clientIp=$1
clientPort=$2

serverIp=$3
serverPort=$4

count=$5

function test {
  file=$1
  window=$2
  out=$3
  echo Testing file: $file, window: $window, count: $count
  for i in $(seq 1 $count) ; do
    outputFile="data/${out}_output_$(date +%s)_$i"
    ./file_client.sh $clientIp $clientPort $window $serverIp $serverPort $file $outputFile
  done
}

function testSize {
  size=$1
  windows=$2
  out=$3
  file="/tmp/data_${size}k"
  cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 1023 | head -n $size > $file
  for w in $windows ; do
    test $file $w $out
  done
}

function testSizes {
  sizes=$1
  windows=$2
  out=$3
  for s in $sizes ; do
    testSize $s "$windows" $out
  done
}

token=$(date +%s)

#echo "Experimento #1"
#serie 1y2
#testSizes "1 2 3 4 $(seq 5 5 200) 500 1000 10000" "10" serie_${token}_exp_1
#serie 3
#testSizes "1 10 100 500 1000 10000 20000 30000 40000 50000" "10" serie_${token}_exp_1
#serie 4
#testSizes "$(seq 1000 1000 20000)" "10" serie_${token}_exp_1
#serie 5
#testSizes "$(seq 500 500 5000)" "10" serie_${token}_exp_1

echo "Experimento #2"
#testSizes "1 10 100 1000 10000" "1 2 3 4 5 $(seq 10 10 100) 150 200" serie_${token}_exp_2
testSizes "1000" "$(seq 90 10 100) 150 200" serie_${token}_exp_2
#testSizes "1 10 100 1000 10000 20000 30000" "1 2 3 4 5 10 30 50 100 200 300 400" serie_${token}_exp_2



